<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="requestInterFace.Handle.userHandle"%>
<%@ page import="xml.response.*"%>
<%@ page import="xml.root"%>
<%@ page import="util.print.printLogCat"%>
<%@ page import="org.sql.table.*"%>
<%@ page import="xml.var"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="requestInterFace.UserInfoInterFace.*"%>
<%@ page import="jqgrid.jqgrid"%>
<%@ page import="xml.var"%>
<%@ include file="../../util/paramPrint.jsp" %>
<%@ page trimDirectiveWhitespaces="true" %> 
<%   

    /*********** jqgrid ******************/
		jqgrid jq=new jqgrid();
		jq.setRows(request.getParameter(jqgrid._rows));
		jq.setSord(request.getParameter(jqgrid._sord));
		jq.setSortname(request.getParameter(jqgrid._sortname));
		jq.setPage(request.getParameter(jqgrid._page));
		jq.setOper(request.getParameter(jqgrid._oper));
		jq.setSearch(request.getParameter(jqgrid._search));
		/*************************************/
		
		
String User_ID = request.getParameter("User_ID");
String name = request.getParameter("User_Name");
String User_type =request.getParameter("User_Type");
String UP_ID =request.getParameter("UP_ID");//业务员ID
String find_Type = request.getParameter("find_Type");
String start_call_time =request.getParameter("start_call_time");//开始访问时间
String end_call_time =request.getParameter("end_call_time");//开始访问时间
String userType=(String)session.getAttribute("User_Type");
String userID=(String)session.getAttribute("User_ID");
			root root=new root();
			userinfo1_1 user=new userinfo1_1();
			
			if(jq.getSortname()!=null&&!jq.getSortname().equals("")){
			user.setOrder(jq.getSortname(),jq.getSord());
			}
			
 	    if(userType!=null&&userType.equals("1")){
			//管理员
		user.setResultField("User_ID").setResultField("User_Name").setResultField("Login_Name").setResultField("Login_Pwd").setResultField("User_Type").
		setResultField("UP_ID").setResultField("Called_Time").
		setResultField("Addr").setResultField("TEL").setResultField("TEL");
		}else if(userType!=null&&userType.equals("2")){
			//业务员
			user.setResultField("User_ID").setResultField("User_Name").setResultField("Login_Name").setResultField("User_Type").setResultField("Called_Time").
		    setResultField("Addr").setResultField("TEL").setResultField("TEL");
			if(find_Type!=null&&!find_Type.equals("")){
			if(find_Type.equals("find_MyUser")){
			user.addequwhile("UP_ID"," = ",userID);
			}else if(find_Type.equals("find_OtherUser")){
			user.addequwhile("UP_ID"," != ",userID);
			}
			}else{
			user.addequwhile("UP_ID"," = ",userID);
			}
			
		}else if(userType!=null&&userType.equals("3")){
			//客户
		user.setResultField("User_ID").setResultField("User_Name").setResultField("Login_Name").setResultField("User_Type").
		setResultField("UP_ID").setResultField("Called_Time").
		setResultField("Addr").setResultField("TEL");
		user.addequwhile("User_ID"," = ",userID);
		}else if(userType!=null&&userType.equals("4")){
			//送货员
		user.setResultField("User_ID").setResultField("User_Name").setResultField("Login_Name").setResultField("User_Type").
		setResultField("UP_ID").setResultField("Called_Time").
		setResultField("Addr").setResultField("TEL");
		}else{
		root.setStatus("false");
		root.setMsg("未登录");
		PrintWriter pw = response.getWriter();
		pw.println(root.getXmlString());
		pw.flush();
		return ;
		}
		user.setLimit((jq.getPageInt()-1)*jq.getRowsInt(), jq.getRowsInt());
		
		if(User_ID!=null&&(!User_ID.equals(""))){
		 user.addequwhile("User_ID","like ","%"+ java.net.URLDecoder.decode(User_ID,"UTF-8")+"%");
		}

		if(User_type!=null&&!User_type.equals("")){
		 user.addequwhile("User_type"," = ",User_type);
		}
		if(UP_ID!=null&&(!UP_ID.equals(""))){
		 user.addequwhile("UP_ID"," = ",UP_ID);
		}
		if(start_call_time!=null&&(!start_call_time.equals(""))){
		  user.addequwhile("Called_Time"," >=",start_call_time);
		}
		if(end_call_time!=null&&(!end_call_time.equals(""))){
		 user.addequwhile("Called_Time"," <=",end_call_time);
		}
		Vector d=user.getTableFactroy();
		
		root.setRecords(""+d.size());//设置当前查询到的记录数
		root.setTotal_Count(""+(user.getCount()/jq.getRowsInt()+1));//查询到的总记录数
		root.setLimit_Offset(""+jq.getPage());//当前查询页面
		for(int i=0;i<d.size();i++){
			userinfo1_1 u=(userinfo1_1)d.elementAt(i);
		response res=new response();
		res.setAttribute_Id(""+i);
		for(int j=0;j<u.getResultFieldNum();j++){
			String field=(String)u.getSql().getResultField().elementAt(j);
    		var v=(var)u.getTable().get(field);
			
			res.put(v.getName(), v);
			
		}
		root.addResponse(res);
		}
		//printLogCat.printlnWriter(root.getXmlString());
		String rep=root.getXmlString();
%>
<%=rep%>